package com.hxc.web.controller.basicdata;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hxc.common.annotation.Log;
import com.hxc.common.core.controller.BaseController;
import com.hxc.common.core.domain.AjaxResult;
import com.hxc.common.enums.BusinessType;
import com.hxc.basicdata.domain.TCompanyInfo;
import com.hxc.basicdata.service.ITCompanyInfoService;
import com.hxc.common.utils.poi.ExcelUtil;
import com.hxc.common.core.page.TableDataInfo;

/**
 * 农村企业信息Controller
 * 
 * @author hxc
 * @date 2021-08-12
 */
@RestController
@RequestMapping("/basicdata/company")
public class TCompanyInfoController extends BaseController
{
    @Autowired
    private ITCompanyInfoService tCompanyInfoService;

    /**
     * 查询农村企业信息列表
     */
    @PreAuthorize("@ss.hasPermi('basicdata:company:list')")
    @GetMapping("/list")
    public TableDataInfo list(TCompanyInfo tCompanyInfo)
    {
        startPage();
        List<TCompanyInfo> list = tCompanyInfoService.selectTCompanyInfoList(tCompanyInfo);
        return getDataTable(list);
    }

    /**
     * 导出农村企业信息列表
     */
    @PreAuthorize("@ss.hasPermi('basicdata:company:export')")
    @Log(title = "农村企业信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TCompanyInfo tCompanyInfo)
    {
        List<TCompanyInfo> list = tCompanyInfoService.selectTCompanyInfoList(tCompanyInfo);
        ExcelUtil<TCompanyInfo> util = new ExcelUtil<TCompanyInfo>(TCompanyInfo.class);
        return util.exportExcel(list, "农村企业信息数据");
    }

    /**
     * 获取农村企业信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('basicdata:company:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tCompanyInfoService.selectTCompanyInfoById(id));
    }

    /**
     * 新增农村企业信息
     */
    @PreAuthorize("@ss.hasPermi('basicdata:company:add')")
    @Log(title = "农村企业信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TCompanyInfo tCompanyInfo)
    {
        return toAjax(tCompanyInfoService.insertTCompanyInfo(tCompanyInfo));
    }

    /**
     * 修改农村企业信息
     */
    @PreAuthorize("@ss.hasPermi('basicdata:company:edit')")
    @Log(title = "农村企业信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TCompanyInfo tCompanyInfo)
    {
        return toAjax(tCompanyInfoService.updateTCompanyInfo(tCompanyInfo));
    }

    /**
     * 删除农村企业信息
     */
    @PreAuthorize("@ss.hasPermi('basicdata:company:remove')")
    @Log(title = "农村企业信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tCompanyInfoService.deleteTCompanyInfoByIds(ids));
    }
}
